package org.example.controller;

import org.example.entry.Cat;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA 2023.
 * Description:
 * User: homechen
 * Date: 2024-03-31
 * Time: 18:30
 */
@Controller
public class CatBean {
    //    @Scope("prototype")
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)   // 原型 / 多例的
    @Bean("cat1")
    public Cat cat() {
        Cat cat = new Cat();
        cat.setId(1);
        cat.setName("加菲猫");
        cat.setAge(12);
        return cat;
    }
}
